﻿namespace AzManAPI
{
    using System;
    using Microsoft.Interop.Security.AzRoles;
    using System.Runtime.InteropServices;

    public class Application : IDisposable
    {
        private IAzApplication3 application;

        public string Name
        {
            get { return application.Name; }
            set
            {
                application.Name = value;
                application.Submit();
            }
        }

        public string Description
        {
            get { return application.Description; }
            set
            {
                application.Description = value;
                application.Submit();
            }
        }

        internal Application(IAzApplication3 application)
        {
            this.application = application;
        }

        #region IDisposable Implementation
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        ~Application()
        {
            Dispose(false);
        }
        
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // free managed resources
                // if not null
                // dispose and set to null
            }

            if (application != null)
            {
                Marshal.ReleaseComObject(application);
                application = null;
            }
        }
#endregion
    }
}